package com.yf.springboot.bean;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;

import java.util.Arrays;
import java.util.Date;

/*
    配置绑定方式一：@Component + @ConfigurationProperties (方式二见AppConfig类)
    @Component //只有容器中的组件才能使用springboot的配置绑定功能
    @ConfigurationProperties: 告诉Springboot将本类中的属性与配置文件中相关的属性进行绑定
    先从application.yml中找，找不到再从employer.properties中找。
 */
@PropertySource(value = {"classpath:employer.properties"})
@ConfigurationProperties(prefix = "employer") // prefix指定配置文件中一级key
public class Employer {
    private String company;
    private Date date;
    private String[] staff;
    private Car car;

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String[] getStaff() {
        return staff;
    }

    public void setStaff(String[] staff) {
        this.staff = staff;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    @Override
    public String toString() {
        return "Employer{" +
                "company='" + company + '\'' +
                ", date=" + date +
                ", staff=" + Arrays.toString(staff) +
                ", car=" + car +
                '}';
    }
}








